function pageNumInit(e) {
    for (var t = [], a = 0; a < e; a++) t[a] = a + 1;
    return t;
}

Component({
    properties: {
        prevText: {
            type: String,
            value: "上一页"
        },
        nextText: {
            type: String,
            value: "下一页"
        },
        page: {
            type: Number,
            value: 0
        },
        limit: {
            type: Number,
            value: 20
        },
        count: {
            type: Number,
            value: 1,
            observer: "_setRange"
        },
        scrollTop: String
    },
    data: {
        sum: 1,
        pageRange: []
    },
    methods: {
        setPage: function(e) {
            this.setData({
                page: e
            });
        },
        _setRange: function(e, t) {
            if (e !== t) {
                var a = Math.ceil(e / this.data.limit);
                this.setData({
                    sum: a,
                    pageRange: pageNumInit(a)
                });
            }
        },
        _onPrev: function() {
            var e = this.data.page - 1;
            e < 0 || this._onChange({
                detail: {
                    value: e
                }
            });
        },
        _onChange: function(e) {
            var t = parseInt(e.detail.value, 10);
            this.setData({
                page: t
            }), this.triggerEvent("change", {
                num: t
            }), this._pageScroll();
        },
        _onNext: function() {
            var e = this.data, t = e.page + 1;
            e.sum <= t || this._onChange({
                detail: {
                    value: t
                }
            });
        },
        _pageScroll: function() {
            var e = this.data.scrollTop;
            if (e) if (/^[0-9]{1,}$/.test(e)) wx.pageScrollTo({
                scrollTop: e
            }); else {
                var t = wx.createSelectorQuery();
                t.select(e).boundingClientRect(), t.selectViewport().scrollOffset(), t.exec(function(e) {
                    wx.pageScrollTo({
                        scrollTop: e[0].top
                    });
                });
            }
        }
    }
});